﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _07_04_DBHelper
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //准备sql语句
            string cmd = "insert into Member(MemberAccount,MemberPwd,MemberName,MemberPhone) " +
               "values(@MemberAccount,@MemberPwd,@MemberName,@MemberPhone)";
            DBHelper.PrepareCmd(cmd);

            //传参数
            DBHelper.SetParamter("MemberAccount",this.textBox1.Text);
            DBHelper.SetParamter("MemberPwd", this.textBox2.Text);
            DBHelper.SetParamter("MemberName", this.textBox3.Text);
            DBHelper.SetParamter("MemberPhone", this.textBox4.Text);
            //执行
            if (DBHelper.ExecNonQuery()>0) {
                MessageBox.Show("新增成功");
            } 
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }
    }
}
